<?php
/**
 *  This file is part of Urd.
 *
 *  Urd is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *  Urd is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. See the file "COPYING". If it does not
 *  exist, see <http://www.gnu.org/licenses/>.
 *
 * $LastChangedDate: 2008-07-19 08:33:18 +0200 (Sat, 19 Jul 2008) $
 * $Rev: 1306 $
 * $Author: styck $
 * $Id: functions.php 1306 2008-07-19 06:33:18Z styck $
 */

if (!defined('ORIGINAL_PAGE')) die('This file cannot be accessed directly.');


function get_default_prefs()
{
    $prefArray = array();
    $prefArray['maxsetname'] = 80;		// nr of chars in a set name, also used for many other fields in the pages
    $prefArray['setsperpage'] = 100;	// number of lines per  page
    $prefArray['minsetsize'] = 0;		// min size in MB per set to be shown
    $prefArray['maxsetsize'] = 0;		// max size in MB per set to be shown
    $prefArray['minngsize'] = 1;		// min nr of post in a ng to be shown
    $prefArray['unrar'] = 1;		// auto unrar
    $prefArray['hiddenfiles'] = 0;		// show hidden files in view files
    $prefArray['hidden_files_list'] = '';	// list of files to be hidden
    $prefArray['unpar'] = 1;		// auto unpar
    $prefArray['search_terms'] = '';	// auto search terms after update is run
    $prefArray['blocked_terms'] = '';	// auto search terms after update is run
    $prefArray['delete_files'] = 1;		// delete redundant files after unpar/rar is complete
    $prefArray['defaultsort'] = 'date DESC';  // sort of the sets page
    $prefArray['mail_user'] = 0;		// mail user when a dl is complete
    $prefArray['template'] = 'default';	// the template used by the user
    $prefArray['language'] = 'english.php';	// the language used by the user
    $prefArray['index_page'] = 'manual';	// the website the user is pointed to when going to the index file
    $prefArray['setcompleteness'] = 0;	// the size of a set in % before it is shown on the browse page
    $prefArray['pref_level'] = CONFIG_LEVEL_BASIC; // the user experience level
    $prefArray['search_type'] = 'LIKE';     // search type for set matching
    $prefArray['screen_width'] = 800;       // width for viewing images
    $prefArray['use_auto_download'] = 0;       // auto downloading based on search terms
    $prefArray['screen_height'] = 600;	// and the height
    $prefArray['global_scripts'] = '';	// enabled global scripts
    $prefArray['user_scripts'] = '';	// enabled user scripts
    $prefArray['taskmax1'] = 5;
    $prefArray['taskmax2'] = 8;
    $prefArray['skip_int'] = 0;	// enabled user scripts
    for ($i = 1 ; $i <= MAX_SEARCH_BUTTONS; $i++)
        $prefArray['button'.$i] = 'none';		// the buttons
    $prefArray['rarfile_size'] = 1000;
    $prefArray['recovery_size'] = 5;
    $prefArray['poster_name'] = '';
    $prefArray['poster_email'] = '';
    $prefArray['format_dl_dir'] = '';
    $prefArray['subs_lang'] = 'en, nl';       //subtitle languages
    $prefArray['download_text_file'] = 1;
    $prefArray['cancel_crypted_rars'] = 0; // Check for encrypted RARs when downloading, and cancel DL if found
    
    return $prefArray;
}


function get_default_config()
{
    $prefArray_root = array();
    $prefArray_root['unrar_path'] = '/usr/bin/rar';
    $prefArray_root['rar_path'] = '/usr/bin/rar'; // add to installer xXX
    $prefArray_root['un7zr_path'] = '/usr/bin/7zr';
    $prefArray_root['unzip_path'] = '/usr/bin/unzip';
    $prefArray_root['gzip_path'] = '/bin/gzip';
    $prefArray_root['unace_path'] = '/usr/bin/ace';
    $prefArray_root['tar_path'] = '/usr/bin/tar';
    $prefArray_root['unarj_path'] = '/usr/bin/arj';
    $prefArray_root['subdownloader_path'] = '/usr/bin/subdownloader';
    $prefArray_root['file_path'] = '/usr/bin/file';
    $prefArray_root['unpar_path'] = '/usr/bin/par2';
    $prefArray_root['cksfv_path'] = '/usr/bin/cksfv';
    $prefArray_root['yydecode_path'] = '/usr/bin/yydecode';
//    $prefArray_root['yyencode_path'] = '/usr/bin/uuenview'; // add to installre XXX
    $prefArray_root['yyencode_path'] = '/usr/local/bin/yencode'; // add to installre XXX
    $prefArray_root['trickle_path'] = '/usr/bin/trickle';
    // Is this the installation? Then $_SESSION contains the actual paths:
    if (isset($_SESSION['7zip']))     $prefArray_root['un7zr_path']    = $_SESSION['7zip'];
    if (isset($_SESSION['tar']))      $prefArray_root['tar_path']      = $_SESSION['tar'];
    if (isset($_SESSION['unrar']))    $prefArray_root['unrar_path']    = $_SESSION['unrar'];
    if (isset($_SESSION['rar']))    $prefArray_root['rar_path']    = $_SESSION['rar'];
    if (isset($_SESSION['unzip']))    $prefArray_root['unzip_path']    = $_SESSION['unzip'];
    if (isset($_SESSION['gzip']))     $prefArray_root['gzip_path']     = $_SESSION['gzip'];
    if (isset($_SESSION['unace']))    $prefArray_root['unace_path']    = $_SESSION['unace'];
    if (isset($_SESSION['file']))     $prefArray_root['file_path']     = $_SESSION['file'];
    if (isset($_SESSION['unarj']))    $prefArray_root['unarj_path']    = $_SESSION['unarj'];
    if (isset($_SESSION['par2']))     $prefArray_root['unpar_path']    = $_SESSION['par2'];
    if (isset($_SESSION['cksfv']))    $prefArray_root['cksfv_path']    = $_SESSION['cksfv'];
    if (isset($_SESSION['yydecode'])) $prefArray_root['yydecode_path'] = $_SESSION['yydecode'];
    if (isset($_SESSION['yyencode'])) $prefArray_root['yyencode_path'] = $_SESSION['yyencode'];
    if (isset($_SESSION['trickle']))  $prefArray_root['trickle_path']  = $_SESSION['trickle'];
    if (isset($_SESSION['subdownloader']))  $prefArray_root['subdownloader_path']  = $_SESSION['subdownloader'];

    $prefArray_root['urdd_path'] = '/var/www/urd/urdd.sh'; // location where urdd is stored
    if (isset($_SESSION['urdd']))  $prefArray_root['urdd_path']  = $_SESSION['urdd'];
    $prefArray_root['urdd_host'] = 'localhost';	// hostname of urdd
    $prefArray_root['shaping'] = 0;			// enable traffic shaping with trickle
    $prefArray_root['auto_expire'] = 1;		// expire msgs after update
    $prefArray_root['dlpath'] = '';			// the path to store files
    if (isset($_SESSION['urddownloaddir']))  {
        $prefArray_root['dlpath']  = realpath($_SESSION['urddownloaddir']);
        if (substr($prefArray_root['dlpath'], -1) != '/')
            $prefArray_root['dlpath'] .= '/';
    }
    $prefArray_root['url'] = '';			// the URL of the webserver
    if (isset($_SESSION['url']))     $prefArray_root['url']    = $_SESSION['url'];
    $prefArray_root['auto_reg'] = 0;		// activate registered users after email confirmation
    $prefArray_root['urdd_port'] = URDD_PORT;
    $prefArray_root['urdd_restart'] = 1;		// restart active tasks after a restart of urdd
    $prefArray_root['urdd_maxthreads'] = 10;
    $prefArray_root['nntp_maxdlthreads'] = 0; // max threads per download
    $prefArray_root['admin_email'] = '';		// email of the urd admin
    if (isset($_SESSION['urdusermail']))     $prefArray_root['admin_email']    = $_SESSION['urdusermail'];
    $prefArray_root['default_expire_time'] = 5; // in days for a newsgroup
    $prefArray_root['expire_incomplete'] = 0; // in days for a newsgroup
    $prefArray_root['expire_percentage'] = 80; // in days for a newsgroup
    $prefArray_root['maxdl'] = 400;			// shaping max dl
    $prefArray_root['maxul'] = 100;			// shaping max up
    $prefArray_root['URD_version'] = get_version();	// current version of urd
    $prefArray_root['period_cd'] = 0;		// clean dir interval in days
    $prefArray_root['time1_cd'] = 0;		// " hours
    $prefArray_root['time2_cd'] = 0;		// " minutes
    $prefArray_root['dir_cd'] = '';			// which dirs
    $prefArray_root['period_opt'] = 0;		// optimise db interval in days
    $prefArray_root['time1_opt'] = 0;		// hours	
    $prefArray_root['time2_opt'] = 0;		// mins
    $prefArray_root['period_ng'] = 0;		// update the ng list interval in days
    $prefArray_root['time1_ng'] = 0;		// hours
    $prefArray_root['time2_ng'] = 0;		// mins
    $prefArray_root['register'] = 0;		// enable user registration
    $prefArray_root['run_update'] = 0;		// the username as which the first ng update will run
    $prefArray_root['update_version'] = '';		// the newest version of urd ready for dl
    $prefArray_root['update_text'] = '';		// text field with newest version
    $prefArray_root['update_type'] = 0;		// type of update, bugfix, security fix etc
    $prefArray_root['time1_update'] = '12';		// hours update urd
    $prefArray_root['time2_update'] = '00';		// mins update urd
    $prefArray_root['period_update'] = 8;		// interval update urd in days
    $prefArray_root['global_hiddenfiles'] = 0;		// show hidden files in view files
    $prefArray_root['global_hidden_files_list'] = '';  // list of files to be hidden
    $prefArray_root['default_template'] = 'default';   // the template used
    $prefArray_root['log_level'] = LOG_INFO;        // the log level for output to the logfile
    $prefArray_root['group'] = '';			// the system group downloaded files are chgrp'ed to
    $prefArray_root['scheduler'] = 'on';		// whether the scheduler is on
    $prefArray_root['usenet_server'] = '';		// not used?
    $prefArray_root['permissions'] = '0644';	// the permission downloaded files will have
    $prefArray_root['default_language'] = 'english.php';// the default language for URD
    $prefArray_root['maxbuttons'] = MAX_SEARCH_BUTTONS; // the maximum number of buttons shown on the browse page
    $prefArray_root['forumusername'] = '';		// the user name @ the forum for getting and setting ext set info
    $prefArray_root['forumpassword'] = '';			// and the password
    $prefArray_root['period_sendinfo'] = 0;		// the frequency setinfo will be merged into the central repository
    $prefArray_root['period_getinfo'] = 0;		// the frequency setinfo will be gotten frmo the central repository
    $prefArray_root['time1_sendinfo'] = 0;		// hours to send setinfo
    $prefArray_root['time1_getinfo'] = 0;		// hours to get setinfo
    $prefArray_root['time2_sendinfo'] = 0;		// minutes to send setinfo
    $prefArray_root['time2_getinfo'] = 0;		// minutes to get setinf
    $prefArray_root['sendmail'] = 0;		// whether email msgs may be send
    $prefArray_root['index_page_root'] = 'browse';	// the default page where the index file links to
    $prefArray_root['preferred_server'] = 0;	// the server used for downloading headers from
    $prefArray_root['webdownload'] = 0;		// allow downloading tarballs in the web interface
    $prefArray_root['maxfilesize'] = 0;		// the max size getinfo allows to access (in kB)
    $prefArray_root['socket_timeout'] = DEFAULT_SOCKET_TIMEOUT;		// the max size getinfo allows to access (in kB)
    $prefArray_root['nntp_maxthreads'] = 8; 
    $prefArray_root['db_intensive_maxthreads'] = 1; 
    $prefArray_root['auto_download'] = 0; 
    $prefArray_root['urdd_pars'] = ''; 
    $prefArray_root['unpar_pars'] = 'r -q';
    $prefArray_root['par_pars'] = 'c -q';
    $prefArray_root['unrar_pars'] = 'x -y -kb -o- -c- -idp';
    $prefArray_root['rar_pars'] = 'a -ed -inul -idp -m5 -r -ep1 -y';
    $prefArray_root['unace_pars'] = 'x -y';
    $prefArray_root['un7zr_pars'] = 'x -y -bd';
    $prefArray_root['unarj_pars'] = 'x -y -i';
    $prefArray_root['subdownloader_pars'] = '-c -q --rename-subs -D';
    $prefArray_root['unzip_pars'] = '-qq -n';
    $prefArray_root['gzip_pars'] = '-q -c';
    $prefArray_root['yydecode_pars']= '-e -b -f';
    $prefArray_root['yyencode_pars']= '-q -m130000 -o';
    $prefArray_root['check_nntp_connections'] = 1;
    $prefArray_root['allow_global_scripts'] = 0;
    $prefArray_root['allow_user_scripts'] = 0;
    $prefArray_root['clean_dir_age'] = 3;
    $prefArray_root['clean_db_age'] = 3;
    $prefArray_root['max_dl_name'] = MAX_DL_NAME;
    $prefArray_root['total_max_articles'] = 0; // total amount of articles an update will download in one go
    $prefArray_root['auto_login'] = '';
    $prefArray_root['compress_nzb'] = 0;
    $prefArray_root['nice_value'] = 0;
    $prefArray_root['replacement_str'] = ' ';
    $prefArray_root['maxexpire'] = MAX_EXPIRE_TIME;

    $prefArray_root['urdd_startup'] = 0;

    $prefArray_root['period_cdb'] = 0;
    $prefArray_root['time1_cdb'] = 0;
    $prefArray_root['time2_cdb'] = 0;
    $prefArray_root['parse_nfo'] = 1;//parse nfo files when previewing
    $prefArray_root['keep_interesting'] = 0; // keep interesting articles on expiring

    $prefArray_root['settype_' . SETTYPE_UNKNOWN ] = '%T %n';	
    $prefArray_root['settype_' . SETTYPE_MOVIE ] = '%T %n %(y) %m %a %l %s %[x] %N ';	
    $prefArray_root['settype_' . SETTYPE_DOCUMENTARY ] = '%T %n %(y) %m %a %l %s %[x] %N ';	
    $prefArray_root['settype_' . SETTYPE_ALBUM ] = '%T %n %(y) %f %g %N';	
    $prefArray_root['settype_' . SETTYPE_TVSERIES ] = '%T %n %e %m %a %[x] %N ';

    $prefArray_root['settype_' . SETTYPE_SOFTWARE ] = '%T %n %(o) %N';	
    $prefArray_root['settype_' . SETTYPE_GAME ] = '%T %n %(o) %N';	
    $prefArray_root['settype_' . SETTYPE_EBOOK ] = '%T %n - %A %(y) %f %g ';	
    $prefArray_root['settype_' . SETTYPE_IMAGE ] = '%T %n %f %g %[x] %N';	
    $prefArray_root['settype_' . SETTYPE_TVSHOW ] = '%T %e %n %m %a %[x] %N ';
    $prefArray_root['settype_' . SETTYPE_OTHER ] = '%T %n';	
    //$prefArray_root[''] = ;
    return $prefArray_root;
}


?>
